#include <bits/stdc++.h>

using namespace std;

int t,n,m,length,v,d,v1,a1,dis;
int l[1000010],r[1000010],sp[100010];
int len,ending;
bool special1,special2,special3,sp1,sp2,sp3;

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int z=0;z<t;z++)
    {
        dis=0;
        special1=false,special2=false,special3=false,sp1=false,sp2=false,sp3=false;
        cin>>n>>m>>length>>v;
        for(int i=0;i<n;i++)
        {
            cin>>d>>v1>>a1;
            if(a1==0)
            {
                special2=true;
                special3=true;
                if(v1<=v)
                {
                    l[i]=-1;
                    r[i]=-1;
                    dis++;
                }
                else
                {
                    sp1=true;
                    l[i]=d;
                    l[i]=length;
                }
            }
            else if(a1>0)
            {
                special1=true;
                special3=true;
                if(v1>v)
                {
                    sp2=true;
                    l[i]=d;
                    r[i]=length;
                }
                else
                {
                    len=ceil((v*v-v1*v1)*1.0/(2*a1));
                    if(d+len<=length)
                    {
                        sp2=true;
                        l[i]=d+len;
                        r[i]=length;
                    }
                    else
                    {
                        dis++;
                        l[i]=-1;
                        r[i]=-1;
                    }
                }
            }
            else
            {
                special1=true;
                special2=true;
                if(v1<=v)
                {
                    dis++;
                    l[i]=-1;
                    r[i]=-1;
                }
                else
                {
                    len=floor((v*v-v1*v1)*1.0/(2*a1));
                    if(d+len>length)
                    {
                        sp3=true;
                        l[i]=d;
                        r[i]=length;
                    }
                    else
                    {
                        sp3=true;
                        l[i]=d;
                        r[i]=d+len;
                    }
                }
            }
        }
        for(int i=0;i<m;i++)
        {
            cin>>sp[i];
        }
        if(special1==false)
        {
            if(sp1==false)
            {
                cout<<"0"<<' ';
                cout<<m<<endl;
            }
            else
            {
                cout<<n-dis<<' ';
                cout<<m-1<<endl;
            }
        }
        else if(special2==false)
        {
            if(sp2==false)
            {
                cout<<n-dis-1<<' ';
                cout<<m<<endl;
            }
            else
            {
                cout<<n-dis-1<<' ';
                cout<<m-1<<endl;
            }
        }
        else if(special3==false)
        {
            if(sp3==false)
            {
                cout<<n-dis-1<<' ';
                cout<<m<<endl;
            }
            else
            {
                cout<<n-dis-1<<' ';
                cout<<m-1<<endl;
            }
        }
        else{
            cout<<n-dis-1<<' '<<m-2<<endl;
        }
    }
    return 0;
}
